// 开始按钮
class startGameBtn extends eui.Component{
    private btn_fx:eui.Image;
    private btn_start:eui.Image;
    private tx_start:eui.Image;
    private btnBg1:eui.Group;
    private btnBg2:eui.Group;
    private isStartBtn:boolean;

    public constructor(startBtnType:boolean=true){
        super();
        this.isStartBtn = startBtnType;
        this.once(eui.UIEvent.COMPLETE,this.onComplete,this);
        this.skinName = "src/Game/gameRoom/DIYBtn/startGameBtnSkin.exml";
    }
    private onComplete(){
        if(this.isStartBtn){
            this.tx_start.source = "startGameBtn_tx_png";
            this.tx_start.x = 41;
        }else{
            this.tx_start.source = "readyGameBtn_tx_png";
            this.tx_start.x = 69;
        }
        this.once(egret.Event.REMOVED_FROM_STAGE,this.onRemove,this);
        this.btn_fx.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onFx,this);
        this.btn_start.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onStart,this);
    }
    private onFx(e:TouchEvent){
        StageData.soundObj.soundSinglePlay("click");
        StageData.GameRoot.dispatchEventWith(GameEvent.CLEW_SHARE);
    }
    private onStart(e:TouchEvent){
        StageData.soundObj.soundSinglePlay("click");
        StageData.GameRoot.dispatchEventWith(GameEvent.START_GAME);
    }
    private onRemove(){
        this.btn_fx.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onFx,this);
        this.btn_start.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onStart,this);
    }   
    public setReady(ready:boolean){
        if(ready){
            this.btnBg1.x = 126;
            this.btnBg2.visible = false;
        }else{
            this.btnBg1.x = 0;
            this.btnBg2.visible = true;
        }
    }
}